
package graphics3d;


public class Ribs {
    
    private final boolean[][] rib;
    
    public Ribs (int n) {
        rib = new boolean[n-1][];
        for (int i = 0; i < n-1; i++)
            rib[i] = new boolean[n-1-i];
    }
    public Ribs (int n, boolean[] rib) {
        this.rib = new boolean[n-1][];
        for (int i = 0; i < n-1; i++)
            this.rib[i] = new boolean[n-1-i];
        for (int i = 0, k = 0; i < n-1; i++)
            for (int j = 0; j < n-1-i; j++, k++)
                this.rib[i][j] = rib[k];
    }
    
    public boolean isConnected(int i, int j) {
        if (i == j) return true;
        if (i > j) {
            int temp = i;
            i = j;
            j = temp;
        }
        return rib[i][j-1-i];
    }
    
}